<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>申请书编辑</title>
<script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript"
	src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript"
	src="${res}/js/keyword/keywordtips.js"></script>	
<script type="text/javascript"
	src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>

<style>
	textarea{overflow:auto;}
</style>

<script type="text/javascript">
$(function(){
	queryflex();
});
/**
 * 申请书提交方法
 */


var ctxpath = "${ctx}";
var prcWin = new progressWin("${res}");//初始化遮罩层
/**
 * 页面初始化方法 所有的都定义在里面
 */
$(document).ready (function() {
	$("#wbox1").click(function() {
		check("check");
		
		
	});
	
	$("#wbox2").click(function() {
		
		check("check");
		
	});
	
	initControl();
	
	$("table.t_css").not("[id='finances']").not("[id='checkbox_table_']").not("[id='budgetsMsg2']").each(function(){
		$(this).find("tr:even").addClass("li_1");
		$(this).find("tr:odd").addClass("li_2");
	});
	$("table").addClass("table01");
	$("#checkbox_table_").removeClass("table01");
	$("#feaReport_upload").removeClass("table01");
	$("#prpProduct_text").removeClass("table01");
	
    $('div').find("[id^='checkbox_dyn_']").find("tr").removeClass("li_1").removeClass("li_2");
    $('div').find("[id^='checkbox_dyn_']").find("td").css("border",'0px solid');
    $('div').find("[id^='checkbox_dyn_']").find("table").removeClass("table01");
	
	updatePdfNotes();
	window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
});

$(document).ready(function() {
	fileInit("feaReport_upload","DOC,DOCX,PDF,WPS");
	fileInit("prpProduct_text","DOC,DOCX,PDF,WPS");
	fileInit("prpContent_upload","DOC,DOCX,PDF,WPS",null,"");
	//fileInitAttach("attachAdd", "JPG,PDF", null, 20, "{'JPG':'3072','PDF':'3072'}");
	$("#prpContent_upload").find(".file").hide();//隐藏文本框
});


$(document).ready(function() {
	$("#org").attr("disabled","true");
	initDepartForComplete("org");
	 initControl();
});

/**
 * 申报日期默认为当前日期
 */
$(document).ready(function() {
	
	var nowDate = '${sercverSysDate1}';
	
    if($("#submit_date").val()==""){
	   $("#submit_date").val(nowDate);
    }

    var v1=$("#prp_version").text();
/*     alert(v1);
    alert($("#qhhfile_code").val()); */
    if(v1==''){
    	$("#qhhfile_code").val("");
    }
});

/**
 * 填写检查
 */
function check(type){

	 setTotalAmt();
	validate($("#basic_info"),"项目内容");
	
    validate($("#fragment-tab10"),"鉴定委员会名单"); 
    validate($("#fragment-tab11"),"鉴定意见"); 
    if(!valResult()){
		irisValShowMsg($("#wbox1"));
		return false;
	}
	if(type=="check"){
		showBox($("#wbox1"), "300px", "200px", "检查通过","1:所有检查全部合格");
	} 
	return true;
}



function setTotalAmt(){
	$('#total_amt').val($("#input_total").val());
	$('#request_amt').val($("#source_apply").val());
}

function backToListqhh(){
	window.location=ctx+'/appProject/criteriaset_edit?flag=init';
}


function submitActionCGJD() {
	/**
	 * 填写检查未通过
	 */
	if (!check())
		return false;
/* 	if(!confirm('本系统中与资金相关字段的金额单位均为万元，请确认证书中填写正确')){
		return false;
	} */
	prcWin.openWin();// 打开遮罩层 提前至此处
	beforeSave();
	var xmlData = prePareXmlData();
	$("#xmlData").val(xmlData);
	var options = {
		beforeSubmit : function() {
			//prcWin.openWin();// 打开遮罩层 //收集数据需要时间 提前至验证通过后
		

		}, // 表单提交前的回调函数
		success : function(data) {
			if (data == null || data == "") {
				scmError(irisNotes.saveErrorNote1);
				
			}else if(data.indexOf("<html>")>=0){
				scmError(irisNotes.saveErrorNote3);
				
			} else{ 
				var obj = eval("(" + data + ")");
				
				if(obj.checkList!=null){
					$("#posCode").val(obj.pos_code);
					$("#prp_version").text(obj.prp_version);
					var list = obj.checkList ;
					for ( var i = 0; i < list.length; i++) {
						irisValaddMsg(list[i]);
					}
					irisValShowMsg($("#wbox1"));
					
				} else if(obj.message=="isSessionError"){
					scmError(irisNotes.saveErrorNote6);	//会话互串，请打开另一个页面登录帐号后再保存申请书
					
				} else if(obj.message=="saveError"){
					scmError(irisNotes.saveErrorNote2);
				} else if (obj.message=="notOrg") {
					scmError(irisNotes.notOrg);
				} else if(obj.message=="sbrSubmit"){
					scmError(irisNotes.saveErrorNote4);
				
				} else if(obj.message=="sbdwSubmit"){
					scmError(irisNotes.saveErrorNote5);
				} else {
					var subGrantCode = $("#subGrantCode").val();
					var grantCode = $("#grantCode").val();
					var menuId = $("#menuId").val();
					
					showThickBox(ctx + "/proposal/prpsubmitok_cgjdzs?grantCode="
							+ grantCode + "&subGrantCode="+subGrantCode+"&menuId=" + menuId
							+ "&TB_iframe=true&height=250&width=500", "成果鉴定证书提交成功");
				}
			}
			prcWin.closeWin();// 关闭遮罩层
		},
		error : function() {
			prcWin.closeWin();// 关闭遮罩层
			scmError(irisNotes.submitErrorNote1);
		},
		url : "/egrantweb/proposal/submit", // 请求URL,可覆盖form的action
		type : "post",// 提交方式 post,get
		timeout:120000
	};
	$("#mainForm").ajaxSubmit(options);
}




</script>
<style>
	textarea{overflow:   auto;}
</style>
</head>
<body>

	<c:set var="xmlstr" value="${xmlData}" />
	<x:parse xml="${xmlstr}" var="xmlData" />
	<input type="hidden" id="childDiv" class="thickbox"/>
	<input type="hidden" id="filePath" value="${ctx}/file/ajax-filedownload?fileCode=" />
	<input type="hidden" id="menuId" value="${param.menuId}" />
	<input type="hidden" id="sysDate" value="${sercverSysDate}" />
	
	<div id="showMessage"></div>
	<div id="content">
		
		<cpt:helpTips key="prpedit" id="prpEditTips"></cpt:helpTips>
		<div class="clear_h15"></div>
		<div class="word_box" id="mainDiv">
			<div class="bar_btn">
				<span class="left"> 
					<c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
					<c:set var="flag_shizhi"><x:out select="$xmlData/data/proposal/flag_shizhi" /></c:set>
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交给单位管理员" onclick="submitActionCGJD()" />
					</security:authorize>
					<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
						<c:if test="${flag_shizhi ne '1' }">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到区主管部门" onclick="submitActionCGJD()" />
					</c:if>
					<c:if test="${flag_shizhi =='1' }">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到市主管部门" onclick="submitActionCGJD()" />
					</c:if>
					</security:authorize> 
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToListqhh()" />
				</span>
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox1"/>
				</span>
					<c:set var="sub_grant_code"><x:out select="$xmlData/data/proposal/sub_grant_code" /></c:set>
					
			</div>
			<div class="bar_b">
				<input type="hidden" id="pdfStatus" value="${pdfStatus}" />
				<span class="right">版本号：<span name="proposal/prp_version" id="prp_version"><x:out select="$xmlData/data/proposal/prp_version" /></span></span>
			</div>
			<form method="post" id="mainForm">
				<input type="hidden" value="${grantCode}" id="grantCode"
					name="grantCode"> 
				<input type="hidden" value="${posCode}" id="posCode" name="posCode"> 
				<input type="hidden" value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes" name="posCodeDes">
				<input type="hidden" value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>" id="pdfCodeDes" name="pdfCodeDes">  
				<input type="hidden" value="${xmlData}" id="xmlData" name="xmlData">
				<input type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode"> 
				<input type="hidden" value="${flag_shizhi}" id="flag_shizhi" name="proposal/flag_shizhi"> 
			</form>
				<div class="word_title">
					<c:set var="statYear">${statYear}</c:set>
					<c:if test="${empty statYear}">
						<c:set var="statYear"><x:out select="$xmlData/data/proposal/stat_year" /></c:set>
					</c:if>
					<input type="hidden" name="proposal/stat_year" value="${statYear}">
					<span name="proposal/grant_name" >科技成果鉴定证书</span><br />					
					<input type="hidden" name="proposal/sub_grant_name" value="<x:out select="$xmlData/data/proposal/sub_grant_name" />" />
					<input type="hidden" name="proposal/grant_code" value="<x:out select="$xmlData/data/proposal/grant_code" />" />  <input type="hidden" name="proposal/psn_code" value="<x:out select="$xmlData/data/proposal/psn_code" />" />
					<input type="hidden" id="grant_no" name="proposal/grant_no" value="<x:out select="$xmlData/data/proposal/grant_no" />" />							
					<input type="hidden" name="proposal/sub_grant_code" value="<x:out select="$xmlData/data/proposal/sub_grant_code" />" />
					<input name="proposal/register_area_code" type="hidden" value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_value" />" />
		            <input name="proposal/register_area_name" type="hidden" value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/area_name" />" />
					<input type="hidden" id="sub_grant_no" name="proposal/sub_grant_no" value="<x:out select="$xmlData/data/proposal/sub_grant_no" />" />
					<input type="hidden" name="proposal/help_grant_code" value="<x:out select="$xmlData/data/proposal/help_grant_code" />" />
					<input type="hidden" id="help_grant_no" name="proposal/help_grant_no" value="<x:out select="$xmlData/data/proposal/help_grant_no" />" />
					<c:set var="nature_value"><x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" /> </c:set>
					<c:set var="formCode" value="${param.formCode}"></c:set>
					<input type="hidden" name="proposal/form_code" value="${formCode}" />
				    <input type="hidden" name="proposal/request_amt" 
							id="request_amt" value="<x:out select="$xmlData/data/proposal/request_amt"/>">
												<input type="hidden" name="proposal/year" value="${year}" />
					<input type="hidden" name="proposal/zh_title" value="<x:out select="$xmlData/data/proposal/zh_title" />" />
					<input type="hidden" name="proposal/recomend_org_name" value="<x:out select="$xmlData/data/proposal/recomend_org_name" />" />
					<input type="hidden" name="proposal/recomend_org_value" value="<x:out select="$xmlData/data/proposal/recomend_org_value" />" />
					<!-- 保存鉴定证书号 -->	
					<input type="hidden" name="proposal/print_no" value="<x:out select="$xmlData/data/proposal/print_no" />" />
					<!-- 保存鉴定批准日期 -->
					<input type="hidden" name="proposal/accept_date" value="<x:out select="$xmlData/data/proposal/accept_date" />" />
					<!-- 保存证书对应申请书的posCode -->
					<input type="hidden" name="proposal/pos_code" value="<x:out select="$xmlData/data/proposal/pos_code" />" />
				 
				 	<input type="hidden" name="organizations/organization[0]/sequence_no" value="1" >
					<input type="hidden" name="organizations/organization[0]@submit_org" value="1" >
					<input type="hidden" name="organizations/organization[0]/org_code" value="<x:out select="$xmlData/data/organizations/organization[@submit_org=1]/org_code"/>" >
									 
				 
				 
				 <!-- 公用的配置界面 -->
				    <jsp:include page="./prpeditmain_public.jsp"><jsp:param value="${xmlstr}" name="xmlstr" /></jsp:include>
				</div>
				<div id="tabnav">
					<ul>
						<li id="tab4" onclick="changeTab(this.id)" class="down" >
						    <a href="###"><span>项目内容</span></a>
						</li>
						<li id="tab5" onclick="changeTab(this.id)" >
						    <a href="###"><span>科技成果完成单位情况</span></a>
						</li>
						<li id="tab6" onclick="changeTab(this.id)">
						    <a href="###"><span>主要研制人员名单</span></a>
						</li>
						
						<li id="tab10" onclick="changeTab(this.id)" >
						    <a href="###"><span>鉴定委员会名单</span></a>
						</li>	
						<li id="tab11" onclick="changeTab(this.id)" >
						    <a href="###"><span>鉴定意见</span></a>
						</li>	
						
					</ul>
				</div>
				<div class="tab_box" id="fragment-tab4">
					<jsp:include page="../equipment/prploansedit_kjcgjdview.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr"	 />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab5" style="display: none">
					<jsp:include page="../../view/equipment/prploansedit_kjcgjd_org.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab6" style="display: none">
					<jsp:include page="../../view/equipment/prploansedit_kjcgjd_mainPsn.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab10" style="display: none">
					<jsp:include page="../content/prpContentEdit_cgjdzs.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				<div class="tab_box" id="fragment-tab11" style="display: none">
					<jsp:include page="../content/prpContentEdit_cgjdzs_exp.jsp">
						<jsp:param value="${xmlstr}" name="xmlstr" />
					</jsp:include>
				</div>
				
			<div class="bar_btn02">
				<span class="left"> 
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交给单位管理员" onclick="submitActionCGJD()" />
					</security:authorize>
					<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
						<c:if test="${flag_shizhi  ne '1' }">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到区主管部门" onclick="submitActionCGJD()" />
					</c:if>
					<c:if test="${flag_shizhi =='1' }">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到市主管部门" onclick="submitActionCGJD()" />
					</c:if>
					</security:authorize> 
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToListqhh()" /> 
				</span>
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox2"/>
				</span>
			</div>
		</div>
		<div class="clear_h15"></div>
	</div>
</body>

</html>